<template>
	<view style="background-color: #F6F6F6;padding: 30rpx;height: 100vh;">
		<view>
			<view style="padding: 40rpx;background-color: #FFFFFF;justify-content: space-between;
			border-radius: 0.5em;" class="u-flex" @click="deleteBrowse">
				<text>清除浏览缓存</text>
				<text style="color: #9B9B9B;font-weight: bold;">{{browseLenth}}条</text>
			</view>
			<view style="padding: 40rpx;background-color: #FFFFFF;margin-top: 50rpx;
			border-radius: 0.5em;">
				<u-cell-group :border="false">
					<u-cell-item title="反馈中心" :border-bottom="false" @click="feedbackClick"></u-cell-item>
					<u-cell-item title="修改密码" :border-bottom="false" v-if="userId != 0" @click="modifyClick"></u-cell-item>
					<u-cell-item title="注销账户" :border-bottom="false" v-if="userId != 0" @click="logOff"></u-cell-item>
					<u-cell-item title="支付记录" :border-bottom="false" v-if="userId != 0"
					@click="paymentClick"></u-cell-item>
				</u-cell-group>
			</view>
			<view style="padding: 40rpx;background-color: #FFFFFF;margin-top: 50rpx;
			border-radius: 0.5em;">
				<u-cell-group :border="false">
					<u-cell-item title="关于西红柿" :border-bottom="false" @click="aboutClick"></u-cell-item>
					<u-cell-item title="IP端口设置" :border-bottom="false" @click="show = true"></u-cell-item>
					<u-cell-item title="退出登录" :border-bottom="false" @click="exitClick"
					v-if="userId != 0"></u-cell-item>
				</u-cell-group>
			</view>
		</view>
		<u-popup mode="center" border-radius="14" v-model="show">
			<view style="padding: 20rpx 50rpx;">
				<u-input placeholder="格式:192.168.1.1:8089" v-model="ipInput"
				style="padding: 20rpx;"></u-input>
				<view style="text-align: center;">
					<button type="primary" size="mini" style="border-radius: 2em;
					padding: 0 80rpx;margin: 10rpx 0;" @click="ipClick">保存</button>
				</view>
			</view>
			
		</u-popup>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				show:false,
				userId:0,
				browseLenth:0,
				ipInput:""
			}
		},
		methods: {
			ipClick(){
				this.show = false
				uni.setStorageSync("ipPort",this.ipInput)
			},
			getUserId(){
				this.userId = uni.getStorageSync("userId") || 0
				
			},
			exitClick(){
				uni.removeStorageSync("userId")
				uni.showToast({
					title:"退出成功",
					success: (res) => {
						this.getUserId()
					}
				})
			},
			getBrowseLenth(){
				this.browseLenth = uni.getStorageSync("bookItemArr").length
			},
			deleteBrowse(){
				uni.showModal({
					title:"是否清空浏览记录",
					success: (res) => {
						if(res.confirm){
							uni.removeStorageSync("bookItemArr")
							this.getBrowseLenth()
							uni.showToast({
								title:"已清空缓存"
							})
						}
					}
				})
			},
			paymentClick(){
				uni.navigateTo({
					url:"./payment/payment"
				})
			},
			aboutClick(){
				uni.navigateTo({
					url:"./about/about"
				})
			},
			modifyClick(){
				uni.navigateTo({
					url:"./modify/modify"
				})
			},
			feedbackClick(){
				uni.navigateTo({
					url:"./feedback/feedback"
				})
			},
			logOff(){
				uni.showToast({
					title:"暂不支持注销账号",
					icon:"none",
					position:"top"
				})
			}
		},
		onShow() {
			this.getUserId()
			this.getBrowseLenth()
		}
	}
</script>

<style>

</style>
